<?php
/*数据库连接*/
$dns = 'mysql:host=127.0.0.1;dbname=Tingjun;charset=utf8';
$pdo = new PDO($dns, 'root', '');
// quarry()方法执行查询类SQL. e.g. SELECT * FROM user
$sql = 'SELECT * FROM `stu`';
$sql = 'SELECT `id` ,`name` FROM `stu` LIMIT 2';
var_dump($pdo->query($sql));
$sql = "INSERT INTO `stu` (`name`) VALUES ('Alice')";
echo '<br>';
// exec() 方法执行非查询类 SQL
var_dump($pdo->exec($sql));
echo '<br>';
var_dump($pdo->lastInsertId());
?>